#!/usr/bin/env python
# coding=utf-8
from toughadmin.tools import pyforms
from toughadmin.tools.pyforms import rules
from toughadmin.tools.pyforms.rules import button_style, input_style


def ikuai_add_form(domains=[]):
    return pyforms.Form(
        pyforms.Dropdown("domain_code", domains, rules.not_null, description=u"域编码", required="required",**input_style),
        pyforms.Textbox("nas_name", description=u"设备名称", required="required", **input_style),
        pyforms.Textbox("nas_ver", description=u"设备版本", required="required", **input_style),
        pyforms.Textbox("nas_addr", description=u"设备地址", required="required", **input_style),
        pyforms.Textbox("api_key", description=u"设备共享密钥", required="required", **input_style),
        pyforms.Textbox("nas_gwid", rules.not_null, description=u"设备gwid", required="required", **input_style),
        pyforms.Textbox("nas_desc", rules.not_null, description=u"设备描述", required="required", **input_style),
        pyforms.Button("submit", type="submit", html=u"<b>提交</b>", **button_style),
        title=u"增加爱快设备",
        action="/ikuai/add",
    )


def ikuai_update_form(domains=[]):
    return pyforms.Form(
        pyforms.Hidden("id", description=u"编号"),
        pyforms.Dropdown("domain_code", domains, rules.not_null, description=u"域编码", required="required",**input_style),
        pyforms.Textbox("nas_name", description=u"设备名称", required="required", **input_style),
        pyforms.Textbox("nas_ver", description=u"设备版本", required="required", **input_style),
        pyforms.Textbox("nas_addr", description=u"设备地址", required="required", **input_style),
        pyforms.Textbox("api_key", description=u"设备共享密钥", required="required", **input_style),
        pyforms.Textbox("nas_gwid", rules.not_null, description=u"设备gwid", required="required", readonly="readonly",**input_style),
        pyforms.Textbox("nas_desc", rules.not_null, description=u"设备描述", required="required", **input_style),
        pyforms.Button("submit", type="submit", html=u"<b>提交</b>", **button_style),
        title=u"修改爱快设备",
        action="/ikuai/update",
    )